<!DOCTYPE html>
<html class="x-admin-sm">
  
  <head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="<?php echo __ACSS__;?>/font.css">
    <link rel="stylesheet" href="<?php echo __ACSS__;?>/xadmin.css">
    <!-- <link rel="stylesheet" href="./css/theme5.css"> -->
    <script src="<?php echo __ALIB__;?>/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="<?php echo __AJS__;?>/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
   <!--[if lt IE 9]>
   <script src="<?php echo __AJS__;?>/html5.min.js"></script>
   <script src="<?php echo __AJS__;?>/respond.min.js"></script>
   <![endif]-->
  </head>
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="/index.php/admin/index/welcome">首页</a>
        <a href="#">
          <cite>文章列表</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" action="/index.php/admin/article/artList" method="post">
                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input"  autocomplete="off" placeholder="开始日" name="start" id="start">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input"  autocomplete="off" placeholder="截止日" name="end" id="end">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="title"  placeholder="请输入文章名" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-header">
                        <button class="layui-btn layui-btn-danger" onclick="xadmin.open('新增文章','/index.php/admin/article/artAdd')"><i class="layui-icon"></i>新增文章</button>
                        <button class="layui-btn layui-btn-warm" onclick="xadmin.open('文章回收站','/index.php/admin/article/delList' )"><i class="layui-icon"></i>回收站</button>
                    </div>
                    <div class="layui-card-body ">
                    <div class="layui-card-body ">
                        <table class="layui-table layui-form" style="text-align: center">
                          <thead>
                            <tr>
                              <th style="text-align: center">ID</th>
                              <th style="text-align: center">文章标题</th>
                              <th style="text-align: center">所属栏目</th>
                              <th style="text-align: center">评论数</th>
                              <th style="text-align: center" width="60px;">缩略图</th>
                              <th style="text-align: center">添加时间</th>
                              <th style="text-align: center">操作</th>
                            </tr>
                          </thead>
                          <tbody>
                            <?php foreach($res as $v){ ?>
                                <tr>
                                    <td><?php echo $v['id']; ?></td>
                                    <td><?php echo $v['title']; ?></td>
                                    <td><?php echo $v['cat_name']; ?></td>
                                    <td><?php echo $v['comm']; ?></td>
                                    <td ><img src="<?php echo __UPLOADS__.'/'.$v['thumb']; ?>" alt=""></td>
                                    <td><?php echo date('Y-m-d H:i:s',$v['add_time']); ?></td>
                                    <td class="td-manage">
                                        <button class="layui-btn layui-btn-warm layui-btn-xs"  onclick="xadmin.open('编辑栏目','<?php echo '/index.php/admin/article/artEdit?id='.$v['id']; ?>')" ><i class="layui-icon">&#xe642;</i>编辑</button>
                                        <button class="layui-btn-danger layui-btn layui-btn-xs"  onclick="member_del(<?php echo $v['id']; ?>)" href="javascript:;" ><i class="layui-icon">&#xe640;</i>删除</button>
                                    </td>
                                    </tr>
                            <?php } ?>

                          </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            <div>
                              <!--<a class="prev" href="">&lt;&lt;</a>-->
                              <!--<span class="current" href="">1</span>-->
                              <!--<a class="num" href="">2</a>-->
                              <!--<a class="num" href="">3</a>-->
                              <!--<a class="next" href="">&gt;&gt;</a>-->
                                <a class="prev <?php if($page==1) echo 'layui-disabled';?>" href="/index.php/admin/article/artList?page=1">&lt;&lt;&lt;</a>
                                <?php foreach($pages[0] as $k=>$v){ if($k==$page){ echo '<span class="current layui-disabled">'.$k.'</span>'; }else{ ?>
                                <a class="num" href="/index.php/admin/article/artList?<?php echo $v; ?>"><?php echo $k; ?></a>
                                <?php } } ?>
                                <a class="prev <?php if($page==$pages[1] || $pages[1]==1) echo 'layui-disabled';?>" href="/index.php/admin/article/artList?page=<?php echo $pages[1];?>">&gt;&gt;&gt;</a>
                                <label>&emsp;共 <?php echo $num;?> 条</label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        </div>
    </div>
    <script>
      layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });


      /*用户-删除*/
      function member_del(id){
          layer.confirm('确认要删除吗？',function(){
              //异步删除
              $.post("/index.php/admin/article/softDel.php",{id:id,del:200}, function (res) {
                  res = JSON.parse(res);
                  if (res.code==500){
                      layer.alert(res.data, {
                          icon: 5
                      })
                  }else{
                      layer.msg(res.data,{icon:1,time:1000});
                      // 对父窗口进行刷新
                      window.setTimeout("xadmin.father_reload()",1000);
                  }
              });
          });
      }


    </script>
  </body>

</html>